home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / prog / ooav3 / ooavzoo.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1994-05-23  |  3.0 KB  |  122 lines

  1. {
  2.         Object-Oriented Archive-viewer: ZOO-part
  3. }
  4.  
  5. unit OOAVZoo;
  6.  
  7. interface
  8.  
  9. uses      Dos,OOAV;
  10.  
  11. const     SIZ_TEXT=20;
  12. const     FNAMESIZE=13;
  13. const     MAX_PACK=1;
  14. const     LO_TAG=$a7dc;
  15. const     HI_TAG=$fdc4;
  16.  
  17.  
  18. type      ZFHeader=record
  19.                      lo_tag:word;
  20.                      hi_tag:word;
  21.                      _type:byte;
  22.                      packing_method:byte;
  23.                      next:longint;      { pos'n of next directory entry }
  24.                      offset:longint;
  25.                      date:word;         { DOS format date }
  26.                      time:word;         { DOS format time }
  27.                      file_crc:word;     { CRC of this file }
  28.                      org_size:longint;
  29.                      size_now:longint;
  30.                      major_ver:byte;
  31.                      minor_ver:byte;
  32.                      deleted:boolean;
  33.                      comment:longint;   { points to comment;  zero if none }
  34.                      cmt_size:word;     { length of comment, 0 if none }
  35.                      unknown:byte;
  36.                      fname:array[0..FNAMESIZE-1] of char;
  37.                    end;
  38.  
  39. type      PZooArchive=^TZooArchive;
  40.           TZooArchive=object(TGeneralArchive)
  41.                         constructor Init;
  42.                         procedure FindFirst(var sr:SearchRec);virtual;
  43.                         procedure FindNext(var sr:SearchRec);virtual;
  44.                       private
  45.                         _FHdr:ZFHeader;
  46.                         procedure GetHeader;
  47.                         procedure GetEntry(var sr:SearchRec);
  48.                       end;
  49.  
  50. implementation
  51.  
  52.  
  53.  
  54. type      zooHeader=record
  55.                       text:array[0..SIZ_TEXT-1] of char;
  56.                       lo_tag:word;
  57.                       hi_tag:word;
  58.                       start:longint;
  59.                       minus:longint;
  60.                       major_ver:char;
  61.                       minor_ver:char;
  62.                     end;
  63.  
  64.  
  65. constructor TZooArchive.Init;
  66. begin
  67.   FillChar(_FHdr,sizeof(_FHdr),0);
  68. end;
  69.  
  70.  
  71. procedure TZooArchive.GetHeader;
  72. var       hdr:zooHeader;
  73.           bc:word;
  74. begin
  75.   seek(_FArchive,0);
  76.   BlockRead(_FArchive,hdr,sizeof(hdr),bc);
  77.   seek(_FArchive,hdr.start);
  78. end;
  79.  
  80.  
  81. procedure TZooArchive.GetEntry(var sr:SearchRec);
  82. var       bc:word;
  83.           b:byte;
  84. begin
  85.   FillChar(_FHdr,SizeOf(_FHdr),#0);
  86.   BlockRead(_FArchive,_FHdr,sizeof(_FHdr),bc);
  87.   with _FHdr do
  88.   begin
  89.     if _Type<>0 then
  90.     begin
  91.       b:=0;sr.Name:='';
  92.       while FName[b]<>#0 do
  93.       begin
  94.         if FName[b]='/' then
  95.           sr.Name:=''
  96.         else
  97.           sr.Name:=sr.Name+FName[b];
  98.         inc(b);
  99.       end;
  100.       sr.Size:=Org_Size;
  101.       if _Type=0 then sr.Size:=0;
  102.       sr.Time:=Date*longint(256*256)+Time;
  103.       Seek(_FArchive,_FHdr.next);
  104.     end;
  105.   end;
  106. end;
  107.  
  108.  
  109. procedure TZooArchive.FindFirst(var sr:SearchRec);
  110. begin
  111.  GetHeader;
  112.  GetEntry(sr);
  113. end;
  114.  
  115.  
  116. procedure TZooArchive.FindNext(var sr:SearchRec);
  117. begin
  118.  GetEntry(sr);
  119. end;
  120.  
  121.  
  122. end.